{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "from math import sin, cos, pi\n",
    "\n",
    "width = height = 50\n",
    "model_matrix = [\n",
    "    7.0,  5.0, -5.0, 0.0,\n",
    "    0.0,  7.0,  7.0, 5.0,\n",
    "    7.0, -5.0,  5.0, 0.0,\n",
    "    0.0,  0.0,  0.0, 1.0\n",
    "]\n",
    "\n",
    "def f(x, y):\n",
    "    return sin(float(x) / width * pi * 2.0), cos(float(y) / height * pi * 2.0)\n",
    "\n",
    "colors = (0xFF0000, 0x00FF00) * width * height\n",
    "vectors = [[f(x, y) for x in range(width)] for y in range(height)]\n",
    "\n",
    "plot = k3d.plot()\n",
    "plot += k3d.vector_field(vectors, colors, model_matrix=model_matrix)\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[0].head_size = 1.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[0].scale = 2.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
